import {
  IsNotEmpty,
  Matches,
  Length,
  IsEmail,
  IsBoolean,
} from 'class-validator';
import { IsNotExistsRule } from '../rules/is-not-exisis.rule';
import { IsConfirmed } from '../rules/is-confirmed';
import { ApiProperty } from '@nestjs/swagger';
export class CreateAuthDto {
  @IsNotEmpty({ message: '用户名不能为空' })
  @Length(5, 20, { message: '用户名长度应该为5-20个字符' })
  @Matches(/^[a-z,0-9,A-Z]+$/i, { message: '请输入英文字母加数字的组合' })
  @IsNotExistsRule('user', {
    message: '该用户名已经被占用了,请重新输入一个用户名',
  })
  @ApiProperty()
  userName: string;
  @IsNotEmpty({ message: '密码输入不能为空' })
  @Length(5, 20, { message: '密码长度应改为5-20个字符' })
  @Matches(/^[a-z,0-9,A-Z]+$/i, { message: '请输入英文字母加数字组合' })
  @IsConfirmed({ message: '两次密码不一致' })
  @ApiProperty()
  passWord: string;
  @IsEmail({}, { message: '输入的邮箱不符合规则' })
  @IsNotExistsRule('user', {
    message: '该邮箱已经被占用了,请重新输入一个邮箱号',
  })
  @IsNotEmpty({ message: '邮箱输入不能为空' })
  @ApiProperty()
  email: string;
  @IsNotEmpty({ message: '名字输入不能为空' })
  @ApiProperty()
  name: string;
  @IsNotEmpty({ message: '输入性别不能为空' })
  @IsBoolean({ message: '输入的性别需要是ture和false' })
  @ApiProperty()
  gender: boolean;
}
